From 5e89cb3c5b175a97979fc267b7bbf6f111f59394 Mon Sep 17 00:00:00 2001 From: Simon Harrer Date: Fri, 15 Mar 2024 15:32:13 +0100 Subject: [PATCH] UPDATE --- CHANGELOG.md | 1 + README.md | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 770da4db..5fe749be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - Fixed a bug where the export to YAML always escaped the unicode characters. +- Added option publish test results to **OpenTelemetry**: `datacontract test --publish-to-opentelemetry` - Added export format **protobuf**: `datacontract export --format protobuf` - Added export format **terraform**: `datacontract export --format terraform` (limitation: only works for AWS S3 right now) - Added export format **sql**: `datacontract export --format sql` diff --git a/README.md b/README.md index e35a2213..bef69a02 100644 --- a/README.md +++ b/README.md @@ -123,9 +123,35 @@ $ EXPORT DATAMESH_MANAGER_API_KEY=xxx $ datacontract test https://demo.datamesh-manager.com/demo279750347121/datacontracts/4df9d6ee-e55d-4088-9598-b635b2fdcbbc/datacontract.yaml --server production --publish ``` +## Scenario: Integration with OpenTelemetry +If you use OpenTelemetry, you can use the data contract URL and append the `--publish-to-opentelemetry` option to send the test results to your OLTP-compatible instance, e.g., Prometheus. +The metric name is "datacontract.cli.test.result" and it uses the following encoding for the result: +| datacontract.cli.test.result | Description | +|-------|---------------------------------------| +| 0 | test run passed, no warnings | +| 1 | test run has warnings | +| 2 | test run failed | +| 3 | test run not possible due to an error | +| 4 | test status unknown | + + +```bash +# Fetch current data contract, execute tests on production, and publish result to open telemetry +$ EXPORT OTEL_SERVICE_NAME=datacontract-cli +$ EXPORT OTEL_EXPORTER_OTLP_ENDPOINT=https://YOUR_ID.apm.westeurope.azure.elastic-cloud.com:443 +$ EXPORT OTEL_EXPORTER_OTLP_HEADERS=Authorization=Bearer%20secret (Optional, when using SaaS Products) +$ EXPORT OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf (Optional, because it is the default value) +# Send to OpenTelemetry +$ datacontract test https://demo.datamesh-manager.com/demo279750347121/datacontracts/4df9d6ee-e55d-4088-9598-b635b2fdcbbc/datacontract.yaml --server production --publish-to-opentelemetry +``` + +Current limitations: +- no gRPC support +- currently, only ConsoleExporter and OTLP Exporter +- Metrics only, no logs yet (but loosely planned) ## Installation