ScyllaDB University Live | Free Virtual Training Event
Learn more
ScyllaDB Documentation Logo Documentation
  • Server
  • Cloud
  • Tools
    • ScyllaDB Manager
    • ScyllaDB Monitoring Stack
    • ScyllaDB Operator
  • Drivers
    • CQL Drivers
    • DynamoDB Drivers
  • Resources
    • ScyllaDB University
    • Community Forum
    • Tutorials
Download
ScyllaDB Docs ScyllaDB C# driver Features OpenTelemetry

OpenTelemetry¶

The driver provides support for session and node level traces using OpenTelemetry instrumentation.

Including OpenTelemetry instrumentation in your code¶

Add the package Cassandra.OpenTelemetry to the project and add the extension method WithOpenTelemetryInstrumentation() when building your cluster:

var cluster = Cluster.Builder()
    .AddContactPoint(Program.ContactPoint)
    .WithOpenTelemetryInstrumentation()
    .Build();

Once you have your .NET application instrumentation configured, Cassandra activities can be captured by adding the source CassandraActivitySourceHelper.ActivitySourceName in the tracer provider builder:

using var tracerProvider = Sdk.CreateTracerProviderBuilder()
    .AddSource(CassandraActivitySourceHelper.ActivitySourceName)
    ...

You can also find an example in the driver’s Github repository of how to implement distributed tracing with OpenTelemetry and the DataStax C# driver in an ASP.NET Core project.

Attributes¶

The table below displays the list of included attributes in this feature:

Attribute

Description

Output Values

db.namespace

The keyspace name.

keyspace in use

db.operation.name

The type name of the operation being executed.

Session_Request({RequestType}) for session level calls and Node_Request({RequestType}) for node level calls

db.query.text

The database statement being executed. Included as optional configuration.

e.g.: SELECT * FROM system.local

db.system

An identifier for the database management system (DBMS) product being used.

cassandra

server.address

The host node.

e.g.: 127.0.0.1

server.port

Port number.

e.g.: 9042

Note that in some cases the driver does not know which keyspace a request is targeting because the driver doesn’t parse CQL query strings.

The console log below displays an example of a full Cassandra activity:

Activity.TraceId:            710e1a99afec9bcd056c9fe825bcbb3c
Activity.SpanId:             bd42cfc78b552cd1
Activity.TraceFlags:         Recorded
Activity.ActivitySourceName: Cassandra.OpenTelemetry
Activity.ActivitySourceVersion: 1.0.0.0
Activity.DisplayName:        Session_Request(SimpleStatement) system
Activity.Kind:               Client
Activity.StartTime:          2024-09-13T14:08:36.9762191Z
Activity.Duration:           00:00:00.0416284
Activity.Tags:
    db.system: cassandra
    db.operation.name: Session_Request(SimpleStatement)
    db.namespace: system
    db.query.text: SELECT * FROM local
Resource associated with Activity:
    service.name: CassandraDemo
    service.version: 1.0.0
    service.instance.id: 5a5d88b9-cc86-4f8a-a206-9b4f507630b9
    telemetry.sdk.name: opentelemetry
    telemetry.sdk.language: dotnet
    telemetry.sdk.version: 1.8.0

Advanced Configuration¶

The instrumentation can be configured to extend the default behavior by using CassandraInstrumentationOptions.

Include Statement as an attribute¶

As mentioned above, the attribute db.query.text is not included by default in the activity. To change it, set the CassandraInstrumentationOptions property IncludeDatabaseStatement as true when building the cluster:

var cluster = Cluster.Builder()
    .AddContactPoint(Program.ContactPoint)
    .AddOpenTelemetryInstrumentation(options => options.IncludeDatabaseStatement = true)
    .Build();

Batch Statement size¶

By default, the OpenTelemetry extension only uses up to 5 child statements of a BatchStatement to generate the db.query.text tag. If you want to change this number, set the CassandraInstrumentationOptions property BatchChildStatementLimit:

var cluster = Cluster.Builder()
    .AddContactPoint(Program.ContactPoint)
    .AddOpenTelemetryInstrumentation(options => options.BatchChildStatementLimit = 10)
    .Build();

Was this page helpful?

PREVIOUS
Native protocol
NEXT
Result paging
  • Create an issue
  • Edit this page

On this page

  • OpenTelemetry
    • Including OpenTelemetry instrumentation in your code
      • Attributes
    • Advanced Configuration
      • Include Statement as an attribute
      • Batch Statement size
ScyllaDB C# driver
  • master
    • master
  • Features
    • Address resolution
    • Authentication and Authorization
    • Automatic failover
    • Column Encryption
    • Driver components
      • ADO.NET
      • Core component
        • Statements
          • Batch statements
          • Per-query keyspace
          • Prepared statements
          • Simple statements
      • Linq component
        • Batch statements with LINQ
      • Mapper component
        • Batch statements with the Mapper
    • Connection heartbeat
    • Connection pooling
    • CQL data types to C# types
      • Date and time representation
      • Nulls and unset
    • Execution Profiles
    • Graph support
    • Cluster and schema metadata
    • Metrics
      • App.Metrics Provider
      • List of metrics
    • Native protocol
    • OpenTelemetry
    • Result paging
    • Parameterized queries
    • Query timestamps
    • Query warnings
    • Request Tracker
    • Routing queries
    • Speculative query execution
    • TLS/SSL
    • Tuning policies
    • User-defined functions and aggregates
    • User-defined types
    • Vector support
  • FAQ
  • Upgrade Guide
  • Examples
  • API Reference
Docs Tutorials University Contact Us About Us
© 2025 ScyllaDB | Terms of Service | Privacy Policy | ScyllaDB, and ScyllaDB Cloud, are registered trademarks of ScyllaDB, Inc.
Last updated on 01 Aug 2025.
Powered by Sphinx 7.4.7 & ScyllaDB Theme 1.8.7
Ask AI