|
1 | | -# OpenTelemetry |
| 1 | +# VirtoCommerce OpenTelemetry Module |
2 | 2 |
|
3 | | -## Overview |
| 3 | +This module provides OpenTelemetry observability for VirtoCommerce Platform — metrics, distributed tracing, and structured logging via OTLP exporter. |
4 | 4 |
|
5 | | -Short overview of what the new module is. |
| 5 | +## Features |
6 | 6 |
|
7 | | -- What is the new or updated experience? |
| 7 | +- **Metrics**: ASP.NET Core, HTTP Client, Runtime, Process, EF Core, Elasticsearch, Redis instrumentation |
| 8 | +- **Distributed Tracing**: ASP.NET Core, HTTP Client, Hangfire, EF Core, Elasticsearch, Redis instrumentation |
| 9 | +- **Logging**: Serilog → OpenTelemetry via OTLP sink, with trace/span ID correlation |
| 10 | +- **Conditional Activation**: Only enabled when explicitly configured |
8 | 11 |
|
9 | | -- Does this module replace an existing module/experience? If yes, what is the transition plan? |
| 12 | +## Prerequisites |
10 | 13 |
|
11 | | -- Does this module has dependency on other ? If yes, list/explain the dependencies. |
| 14 | +- VirtoCommerce Platform 3.1002.0+ |
| 15 | +- OTLP-compatible collector (e.g. [Grafana Alloy](https://grafana.com/docs/alloy/), [OpenTelemetry Collector](https://opentelemetry.io/docs/collector/), [Aspire Dashboard](https://learn.microsoft.com/en-us/dotnet/aspire/fundamentals/dashboard/overview)) |
12 | 16 |
|
13 | | -- List the key deployment scenarios - why would people use this module? |
| 17 | +## Installation |
14 | 18 |
|
15 | | -## Functional Requirements |
| 19 | +Copy the module to your platform `modules` directory. It will be automatically discovered and loaded by VirtoCommerce Platform. |
16 | 20 |
|
17 | | -Short description of the new module functional requirements. |
| 21 | +## Configuration |
18 | 22 |
|
19 | | -## Scenarios |
| 23 | +Add to `appsettings.json`: |
20 | 24 |
|
21 | | -List of scenarios that the new module implements |
| 25 | +```json |
| 26 | +{ |
| 27 | + "OpenTelemetry": { |
| 28 | + "Enabled": true, |
| 29 | + "Endpoint": "http://localhost:4317", |
| 30 | + "ServiceName": "VirtoCommerce.Platform" |
| 31 | + } |
| 32 | +} |
| 33 | +``` |
22 | 34 |
|
23 | | -1. [Scenario 1](/doc/scenario-name1.md) |
24 | | -1. [Scenario 2](/doc/scenario-name2.md) |
25 | | -1. [Scenario 3](/doc/scenario-name3.md) |
26 | | - 1. [Scenario 3.1](/doc/scenario-name31.md) |
27 | | - 1. [Scenario 3.2](/doc/scenario-name32.md) |
28 | | -1. [Scenario 4](/doc/scenario-name4.md) |
| 35 | +| Key | Required | Default | Description | |
| 36 | +|-----|----------|---------|-------------| |
| 37 | +| `Enabled` | Yes | `false` | Enables the module. Set to `true` to activate. | |
| 38 | +| `Endpoint` | Yes | — | OTLP collector endpoint (gRPC). Required to export data. | |
| 39 | +| `ServiceName` | No | `VirtoCommerce.Platform` | Service name reported in telemetry. | |
29 | 40 |
|
30 | | -## Web API |
| 41 | +Settings can also be provided via environment variables: |
31 | 42 |
|
32 | | -Web API documentation for each module is built out automatically and can be accessed by following the link bellow: |
33 | | -<https://link-to-swager-api> |
| 43 | +``` |
| 44 | +OpenTelemetry__Enabled=true |
| 45 | +OpenTelemetry__Endpoint=http://collector:4317 |
| 46 | +OpenTelemetry__ServiceName=my-store |
| 47 | +``` |
34 | 48 |
|
35 | | -## Database Model |
| 49 | +## What Gets Collected |
36 | 50 |
|
37 | | - |
| 51 | +### Metrics |
38 | 52 |
|
39 | | -## Related topics |
| 53 | +| Source | Description | |
| 54 | +|--------|-------------| |
| 55 | +| ASP.NET Core | Request rate, duration, active connections | |
| 56 | +| HTTP Client | Outbound request duration and status | |
| 57 | +| .NET Runtime | GC, thread pool, memory | |
| 58 | +| Process | CPU, memory | |
| 59 | +| EF Core | Query counts and duration | |
| 60 | +| Elasticsearch | Transport-level metrics | |
| 61 | +| Kestrel | Connection and request metrics | |
40 | 62 |
|
41 | | -[Some Article1](some-article1.md) |
| 63 | +### Traces |
42 | 64 |
|
43 | | -[Some Article2](some-article2.md) |
| 65 | +| Source | Description | |
| 66 | +|--------|-------------| |
| 67 | +| ASP.NET Core | Incoming HTTP requests | |
| 68 | +| HTTP Client | Outbound HTTP calls | |
| 69 | +| EF Core | Database queries | |
| 70 | +| Hangfire | Background job execution | |
| 71 | +| Elasticsearch | Search and index operations | |
| 72 | +| Redis | Cache operations | |
| 73 | + |
| 74 | +### Logs |
| 75 | + |
| 76 | +Structured logs are forwarded to the OTLP endpoint via Serilog with trace/span ID fields for correlation with distributed traces. |
| 77 | + |
| 78 | +## Module Structure |
| 79 | + |
| 80 | +``` |
| 81 | +src/ |
| 82 | +└── VirtoCommerce.OpenTelemetry.Web/ |
| 83 | + ├── Module.cs # Module entry point |
| 84 | + ├── ServiceCollectionExtensions.cs # OTel metrics and tracing registration |
| 85 | + ├── OpenTelemetryLoggerConfigurationService.cs # Serilog → OTLP logging |
| 86 | + └── VirtoCommerce.OpenTelemetry.Web.csproj |
| 87 | +``` |
| 88 | + |
| 89 | +## Troubleshooting |
| 90 | + |
| 91 | +**Module not activating** — verify `OpenTelemetry:Enabled` is `true` in configuration. |
| 92 | + |
| 93 | +**No data exported** — verify `OpenTelemetry:Endpoint` is set and the collector is reachable. |
| 94 | + |
| 95 | +**Traces missing correlations** — ensure the collector supports OTLP gRPC on the configured endpoint. |
44 | 96 |
|
45 | 97 | ## License |
46 | 98 |
|
47 | | -Copyright (c) Virto Solutions LTD. All rights reserved. |
| 99 | +Copyright (c) Virto Solutions LTD. All rights reserved. |
48 | 100 |
|
49 | | -Licensed under the Virto Commerce Open Software License (the "License"); you |
50 | | -may not use this file except in compliance with the License. You may |
51 | | -obtain a copy of the License at |
| 101 | +Licensed under the Virto Commerce Open Software License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at |
52 | 102 |
|
53 | 103 | <https://virtocommerce.com/open-source-license> |
54 | | - |
55 | | -Unless required by applicable law or agreed to in writing, software |
56 | | -distributed under the License is distributed on an "AS IS" BASIS, |
57 | | -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
58 | | -implied. |
|
0 commit comments