Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
**/*.db
**/*.md
LICENSE
README.md
13 changes: 13 additions & 0 deletions Mocha.sln
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
README.md = README.md
.github\workflows\dotnet-build.yml = .github\workflows\dotnet-build.yml
README.zh-CN.md = README.zh-CN.md
codecov.yml = codecov.yml
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mocha.Storage", "src\Mocha.Storage\Mocha.Storage.csproj", "{8EEB6697-B975-430D-9CC3-3048E76C5ECA}"
Expand Down Expand Up @@ -64,6 +65,15 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mocha.Antlr4.Generated", "s
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mocha.Storage.Benchmarks", "tests\Mocha.Storage.Benchmarks\Mocha.Storage.Benchmarks.csproj", "{4B63E7B0-C8C8-4206-A113-A3D4EFB7533E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "grafana", "grafana", "{5B280BB9-A7AE-46E6-B735-CF484965A736}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "provisioning", "provisioning", "{C6E71F9B-BB5B-4946-9732-96CBA0B366B3}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "datasources", "datasources", "{8FAF9AF6-7399-41FC-96C9-43756AAD16CB}"
ProjectSection(SolutionItems) = preProject
docker\grafana\provisioning\datasources\mocha-datasources.yaml = docker\grafana\provisioning\datasources\mocha-datasources.yaml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -85,6 +95,9 @@ Global
{D56CA47A-A948-4FB5-9E16-C61E12535521} = {24F9E34A-D92A-4C0A-851F-1E864181BF97}
{904CC523-A2D4-4982-8A7B-A6A0F5A5EB19} = {6983D239-07DA-4DFA-9AAA-F6876029FF8D}
{4B63E7B0-C8C8-4206-A113-A3D4EFB7533E} = {24F9E34A-D92A-4C0A-851F-1E864181BF97}
{5B280BB9-A7AE-46E6-B735-CF484965A736} = {D598862A-999C-40FD-A190-EBD00376D077}
{C6E71F9B-BB5B-4946-9732-96CBA0B366B3} = {5B280BB9-A7AE-46E6-B735-CF484965A736}
{8FAF9AF6-7399-41FC-96C9-43756AAD16CB} = {C6E71F9B-BB5B-4946-9732-96CBA0B366B3}
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DCA600F0-4D6C-44DA-A493-F63097CCE74E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
Expand Down
3 changes: 3 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
coverage:
status:
project: off
16 changes: 9 additions & 7 deletions docker/distributor/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ WORKDIR /app
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["src/Mocha.Distributor/Mocha.Distributor.csproj", "src/Mocha.Distributor/"]
COPY ["src/Mocha.Core/Mocha.Core.csproj", "src/Mocha.Core/"]
COPY ["src/Mocha.Protocol.Generated/Mocha.Protocol.Generated.csproj", "src/Mocha.Protocol.Generated/"]
COPY ["src/Mocha.Storage/Mocha.Storage.csproj", "src/Mocha.Storage/"]
RUN dotnet restore "src/Mocha.Distributor/Mocha.Distributor.csproj"
COPY . .
WORKDIR "/src/src/Mocha.Distributor"
COPY ["src/Mocha.Distributor/Mocha.Distributor.csproj", "Mocha.Distributor/"]
COPY ["src/Mocha.Core/Mocha.Core.csproj", "Mocha.Core/"]
COPY ["src/Mocha.Protocol.Generated/Mocha.Protocol.Generated.csproj", "Mocha.Protocol.Generated/"]
COPY ["src/Mocha.Storage/Mocha.Storage.csproj", "Mocha.Storage/"]
RUN dotnet restore "Mocha.Distributor/Mocha.Distributor.csproj"
COPY src/ .
WORKDIR "/src/Mocha.Protocol.Generated"
RUN dotnet build "Mocha.Protocol.Generated.csproj" -c $BUILD_CONFIGURATION
WORKDIR "/src/Mocha.Distributor"
RUN dotnet build "Mocha.Distributor.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
Expand Down
4 changes: 3 additions & 1 deletion docker/docker-compose-mysql-influxdb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ services:
container_name: mocha-grafana
ports:
- "3000:3000"
# volumes:
volumes:
- ./grafana/provisioning:/etc/grafana/provisioning
# If you want to persist Grafana data, uncomment the following lines
# - ./grafana:/var/lib/grafana
restart: always
networks:
Expand Down
3 changes: 2 additions & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ services:
container_name: mocha-grafana
ports:
- "3000:3000"
volumes:
- ./grafana/provisioning:/etc/grafana/provisioning
# If you want to persist Grafana data, uncomment the following lines
# volumes:
# - ./grafana:/var/lib/grafana
restart: always
networks:
Expand Down
23 changes: 23 additions & 0 deletions docker/grafana/provisioning/datasources/mocha-datasources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: 1

datasources:
# Tracing (Jaeger)
- name: mocha-tracing
type: jaeger
uid: mocha-tracing
access: proxy
url: http://query:5775/jaeger
isDefault: false
editable: false

# Metrics (Prometheus API)
- name: mocha-metrics
type: prometheus
uid: mocha-metrics
access: proxy
url: http://query:5775/prometheus
isDefault: true
editable: false

jsonData:
httpMethod: POST
16 changes: 8 additions & 8 deletions docker/query/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ RUN apt-get update && \
rm -rf /var/lib/apt/lists/*

WORKDIR /src
COPY ["src/Mocha.Query/Mocha.Query.csproj", "src/Mocha.Query/"]
COPY ["src/Mocha.Antlr4.Generated/Mocha.Antlr4.Generated.csproj", "src/Mocha.Antlr4.Generated/"]
COPY ["src/Mocha.Core/Mocha.Core.csproj", "src/Mocha.Core/"]
COPY ["src/Mocha.Protocol.Generated/Mocha.Protocol.Generated.csproj", "src/Mocha.Protocol.Generated/"]
COPY ["src/Mocha.Storage/Mocha.Storage.csproj", "src/Mocha.Storage/"]
RUN dotnet restore "src/Mocha.Query/Mocha.Query.csproj"
COPY . .
WORKDIR "/src/src/Mocha.Query"
COPY ["src/Mocha.Query/Mocha.Query.csproj", "Mocha.Query/"]
COPY ["src/Mocha.Antlr4.Generated/Mocha.Antlr4.Generated.csproj", "Mocha.Antlr4.Generated/"]
COPY ["src/Mocha.Core/Mocha.Core.csproj", "Mocha.Core/"]
COPY ["src/Mocha.Protocol.Generated/Mocha.Protocol.Generated.csproj", "Mocha.Protocol.Generated/"]
COPY ["src/Mocha.Storage/Mocha.Storage.csproj", "Mocha.Storage/"]
RUN dotnet restore "Mocha.Query/Mocha.Query.csproj"
COPY src/ .
WORKDIR "/src/Mocha.Query"
RUN dotnet build "Mocha.Query.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
Expand Down
68 changes: 37 additions & 31 deletions docs/quick-start/docker-compose/quick-start.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,25 @@ Configure the OTLP exporter of the SDK as `http://localhost:4317` to send data t

## Query Data

Visit http://localhost:3000/ to see the grafana login page. Both the username and password are admin.

### Trace

#### Configure Jaeger Data Source
#### Query Trace Data

We have implemented an API that supports the Jaeger query protocol, so you can configure the Jaeger data source directly in Grafana.
We have implemented an API that supports the Jaeger query protocol, so you can configure mocha as a Jaeger data source in Grafana to query Trace data.

Visit http://localhost:3000/ to see the grafana login page. Both the username and password are admin.
The Jaeger data source has been pre-configured in `docker/grafana/provisioning/datasources/mocha-datasources.yaml`.

Click the menu on the left, select Explore, and then select the mocha-tracing data source to see the Trace data.

![](./assets/query-trace.png)

![](./assets/query-trace-2.png)

#### Configure Jaeger Data Source

If you need to manually configure the Trace data source, you can refer to the following steps.

After logging in, click the menu on the left, select Data Sources, and then click Add data source.

Expand All @@ -61,21 +73,35 @@ If no data has been sent to the distributor yet, the following warning message w

![](./assets/add-jaeger-data-source-warning.png)

#### Query Trace Data
### Metrics

Click the menu on the left, select Explore, and then select the mocha-tracing data source to see the Trace data.
#### Query Metrics Data

![](./assets/query-trace.png)
We have implemented an API that supports the PromQL query protocol, so you can configure mocha as a Prometheus data source in Grafana to query Metrics data.

![](./assets/query-trace-2.png)
The Prometheus data source has been pre-configured in `docker/grafana/provisioning/datasources/mocha-datasources.yaml`.

### Metrics
Click the menu on the left, select Explore, and then select the Prometheus data source to see the Metrics data.

#### Configure Prometheus Data Source
![](./assets/query-metrics.png)

We have implemented an API that supports the PromQL query protocol, so you can configure the Prometheus data source directly in Grafana.
Click the menu on the left, select Dashboards, and then create a new dashboard.

Visit http://localhost:3000/ to see the grafana login page. Both the username and password are admin.
![](./assets/create-metrics-dashboard.png)

![](./assets/create-metrics-dashboard-2.png)

Select the mocha-metrics data source that we just created.

![](./assets/create-metrics-dashboard-3.png)

After that, you can add panels as needed to display Metrics data.

![](./assets/create-metrics-dashboard-4.png)

#### Configure Prometheus Data Source

If you need to manually configure the Metrics data source, you can refer to the following steps.

After logging in, click the menu on the left, select Data Sources, and then click Add data source.

Expand All @@ -96,23 +122,3 @@ Configure the HTTP Method as POST.
Click Save & Test. If the following information is displayed, the configuration is successful.

![](./assets/add-prometheus-data-source-4.png)

#### Query Metrics Data

Click the menu on the left, select Explore, and then select the Prometheus data source to see the Metrics data.

![](./assets/query-metrics.png)

Click the menu on the left, select Dashboards, and then create a new dashboard.

![](./assets/create-metrics-dashboard.png)

![](./assets/create-metrics-dashboard-2.png)

Select the mocha-metrics data source that we just created.

![](./assets/create-metrics-dashboard-3.png)

After that, you can add panels as needed to display Metrics data.

![](./assets/create-metrics-dashboard-4.png)
73 changes: 40 additions & 33 deletions docs/quick-start/docker-compose/quick-start.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,27 @@ docker-compose up --build -d

## 数据的查询

访问 http://localhost:3000/ 即可看到grafana的登录页面。用户名和密码都是admin。

### Trace

#### 配置 Jaeger 数据源
#### Trace 数据的查询

我们实现了支持 Jaeger 查询协议的 API,因此可以直接在 Grafana 中配置 Jaeger 数据源
我们实现了支持 Jaeger 查询协议的 API,因此可以在 Grafana 中配置 mocha 作为 Jaeger 数据源就可以查询 Trace 数据

访问 http://localhost:3000/ 即可看到grafana的登录页面。用户名和密码都是admin
在 `docker/grafana/provisioning/datasources/mocha-datasources.yaml` 中已经预配置好了 Jaeger 数据源

登录后,点击左侧的菜单,选择 Data Sources,然后点击 Add data source。
点击左侧的菜单,选择 Explore,然后选择 mocha-tracing 数据源,即可看到 Trace 数据。

![](./assets/query-trace.png)

![](./assets/query-trace-2.png)

#### 配置 Trace 数据源

如果需要手动配置 Trace 数据源,可以参考下面的步骤。

登录 grafana 后,点击左侧的菜单,选择 Data Sources,然后点击 Add data source。

![](./assets/add-jaeger-data-source.png)

Expand All @@ -60,23 +72,38 @@ docker-compose up --build -d

![](./assets/add-jaeger-data-source-warning.png)

#### Trace 数据的查询
### Metrics

点击左侧的菜单,选择 Explore,然后选择 mocha-tracing 数据源,即可看到 Trace 数据。
#### Metrics 数据的查询

![](./assets/query-trace.png)
我们实现了支持 PromQL 查询协议的 API,因此可以在 Grafana 中配置 mocha 作为 Prometheus 数据源就可以查询 Metrics 数据。

![](./assets/query-trace-2.png)
在 `docker/grafana/provisioning/datasources/mocha-datasources.yaml` 中已经预配置好了 Prometheus 数据源。

### Metrics
点击左侧的菜单,选择 Explore,然后选择 mocha-metrics 数据源,即可看到 Metrics 数据。

#### 配置 Prometheus 数据源
![](./assets/query-metrics.png)

我们实现了支持 PromQL 查询协议的 API,因此可以直接在 Grafana 中配置 Prometheus 数据源
点击左侧的菜单,选择 Dashboards,即可创建一个 Dashboard

访问 http://localhost:3000/ 即可看到grafana的登录页面。用户名和密码都是admin。
![](./assets/create-metrics-dashboard.png)

![](./assets/create-metrics-dashboard-2.png)

登录后,点击左侧的菜单,选择 Data Sources,然后点击 Add data source。
选择我们刚刚创建的 Prometheus 数据源。

![](./assets/create-metrics-dashboard-3.png)

接下来就可以根据需要添加 Panel,展示 Metrics 数据了。

![](./assets/create-metrics-dashboard-4.png)


#### 配置 Prometheus 数据源

如果需要手动配置 Prometheus 数据源,可以参考下面的步骤。

登录 grafana 后,点击左侧的菜单,选择 Data Sources,然后点击 Add data source。

选择 Prometheus。

Expand All @@ -95,23 +122,3 @@ docker-compose up --build -d
点击 Save & Test,如果显示如下信息,则说明配置成功。

![](./assets/add-prometheus-data-source-4.png)

#### Metrics 数据的查询

点击左侧的菜单,选择 Explore,然后选择 mocha-metrics 数据源,即可看到 Metrics 数据。

![](./assets/query-metrics.png)

点击左侧的菜单,选择 Dashboards,即可创建一个 Dashboard。

![](./assets/create-metrics-dashboard.png)

![](./assets/create-metrics-dashboard-2.png)

选择我们刚刚创建的 Prometheus 数据源。

![](./assets/create-metrics-dashboard-3.png)

接下来就可以根据需要添加 Panel,展示 Metrics 数据了。

![](./assets/create-metrics-dashboard-4.png)
2 changes: 1 addition & 1 deletion src/Mocha.Antlr4.Generated/Mocha.Antlr4.Generated.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<PackageReference Include="Antlr4.Runtime.Standard" Version="4.13.1"/>
<PackageReference Include="Antlr4BuildTasks" Version="12.8.0" PrivateAssets="all"/>
<PackageReference Include="Antlr4BuildTasks" Version="12.11.0" PrivateAssets="all"/>
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/Mocha.Distributor/Mocha.Distributor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Grpc.AspNetCore" Version="2.59.0" />
<PackageReference Include="Grpc.AspNetCore.Server.Reflection" Version="2.59.0" />
<PackageReference Include="Grpc.AspNetCore" Version="2.76.0" />
<PackageReference Include="Grpc.AspNetCore.Server.Reflection" Version="2.76.0" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions src/Mocha.Protocol.Generated/Mocha.Protocol.Generated.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.25.1" />
<PackageReference Include="Grpc.Net.Client" Version="2.59.0" />
<PackageReference Include="Grpc.Tools" Version="2.60.0">
<PackageReference Include="Google.Protobuf" Version="3.33.2" />
<PackageReference Include="Grpc.Net.Client" Version="2.76.0" />
<PackageReference Include="Grpc.Tools" Version="2.76.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,14 @@ public static IEnumerable<JaegerTrace> ToJaegerTraces(
{
resourceAttributesBySpanId.TryGetValue(span.SpanID, out var attributes);
attributes ??= Array.Empty<EFResourceAttribute>();
var serviceName = attributes
.FirstOrDefault(a => a.Key == "service.name")?.Value ?? string.Empty;
var process = new JaegerProcess
{
ProcessID = span.ProcessID,
ServiceName = attributes
.FirstOrDefault(a => a.Key == "service.name")?.Value ?? string.Empty,
ProcessID = string.IsNullOrWhiteSpace(span.ProcessID)
? serviceName
: span.ProcessID,
ServiceName = serviceName,
Tags = Array.ConvertAll(attributes, ToJaegerTag)
};

Expand Down
Loading
Loading