Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Open Telemetry #2449

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

tommasodotNET
Copy link

@tommasodotNET tommasodotNET commented Nov 4, 2024

Why make this change?

Initial implementation to add open-telemetry support (reference #2397)

What is this change?

The user can add the open-telemetry configuration in the dab-config.json file as follows:

{
  "runtime": {
    ...
    "telemetry": {
      "open-telemetry": {
        "enabled": true,
        "service-name": "dab", // has a default value
        "endpoint": "OTEL_ENDPOINT",
        "headers": "x-otlp-api-key=OTEL_API_KEY" // if needed
      }
    }
    ...
  }
}

This configuration can be used alongside the current Application Insights instrumentation, to send logs, traces and metrics to both.

Currently, metrics and traces sent to OTEL comes from AspNetCore and the HttpClients.

The OpenTelemetry implementation only supports dotnet 8.

How was this tested?

  • Unit Tests

schemas/dab.draft.schema.json Show resolved Hide resolved
schemas/dab.draft.schema.json Outdated Show resolved Hide resolved
src/Config/ObjectModel/OpenTelemetryOptions.cs Outdated Show resolved Hide resolved
src/Service/Azure.DataApiBuilder.Service.csproj Outdated Show resolved Hide resolved
src/Service/Program.cs Outdated Show resolved Hide resolved
src/Service/Startup.cs Outdated Show resolved Hide resolved
src/Service/Startup.cs Outdated Show resolved Hide resolved
src/Service/Program.cs Show resolved Hide resolved
src/Service/Program.cs Show resolved Hide resolved
@abhishekkumams abhishekkumams changed the title 2397 otel Add support for Open Telemetry Nov 7, 2024
@abhishekkumams
Copy link
Contributor

Thanks @tommasodotNET for taking up this feature.

Added few comments.

Also,

  1. Would it possible to add some integration tests that validate the complete workflow.
    and having some assertions to check that traces are created for specific operations or that metrics have the expected values?

  2. For actual testing where were you checking the exported data? Can you add some information on that as well?

@tommasodotNET
Copy link
Author

Hi @abhishekkumams. I've added some tests for the CLI. As for actual testing I have no idea at the moment. We would need an OTEL endpoint...

@abhishekkumams
Copy link
Contributor

/azp run

@abhishekkumams
Copy link
Contributor

@tommasodotNET , there are some formatting errors in your PR. you can run dotnet format command it will fix the failure.

@JerryNixon
Copy link
Contributor

JerryNixon commented Nov 16, 2024

Before we can merge, we need to ensure we have a custom Activity called EntityOp.

Configuration change

This setting is obeyed regardless of host.mode value.

{
  "runtime": {
    "telemetry": {
      "open-telemetry": {
        "include-sensitive-data": <boolean, default: false>
      }
    }
  }
}

Activity lineage

# Name Type Description
1 EntityOp Activity Entire operation.
1.1 Request Event Incoming HTTP/GraphQL request.
1.2 PreDatabase Child-Activity Pre-database operations.
1.3 Database Event Database query execution.
1.4 PostDatabase Child-Activity Post-database processing.
1.5 Response Event Outgoing HTTP/GraphQL response.

1. EntityOp (Activity)

Tags:

  • entity.name
  • operation.endpoint_kind rest|graphql
  • operation.kind create|read|update|delete|execute
  • opreation.duration_ms
  • operation.success true|false

1.1 Request (Event)

Tags:

  • http.method
  • http.url ⚠️ sensative-data
  • http.query_params ⚠️ sensative-data

1.2 PreDatabase (Activity)

The reason this is an activity is to allow for potential future Script events for pre-database operations, such as validation or transformation.

Tags:

  • pre_database.script_count
  • pre_database.success

1.2.1 Script (Event)

Tags:

  • script.index
  • script.duration_ms
  • script.result

1.3 Database (Event)

Tags:

  • db.statement ⚠️ sensative-data
  • db.query.rows_returned

1.4 PostDatabase (Activity)

The reason this is an activity is to allow for potential future Script events for post-database processing, such as data enrichment or aggregation.

Tags:

  • post_database.script_count
  • post_database.success

1.4.1 Script (Event)

Tags:

  • script.index
  • script.duration_ms
  • script.result

1.5 Response (Event)

Tags:

  • http.status_code
  • http.response.size

The Script (Event) entries are placeholders for future implementations. Including them now highlights why PreDatabase and PostDatabase are designed as activities—they can group and manage multiple scripts when implemented later.

@abhishekkumams
Copy link
Contributor

Few Things:

  1. Lets Add Custom Activity in a separate PR.
  2. Can you check Telemetry Channel for OpenTelemetry, just like we have for ApplicationInsights(TelemetryTests.cs)
  3. I'll take a look on your current changes as why the Logs are not being sent to OTel?

@abhishekkumams
Copy link
Contributor

/azp run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants