Socket
Socket
Sign inDemoInstall

@opentelemetry/sql-common

Package Overview
Dependencies
Maintainers
3
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/sql-common

Utilities for SQL instrumentations


Version published
Maintainers
3
Created

What is @opentelemetry/sql-common?

@opentelemetry/sql-common is a package that provides common utilities and types for instrumenting SQL databases with OpenTelemetry. It helps in tracing and monitoring SQL queries by providing a standardized way to collect and report telemetry data.

What are @opentelemetry/sql-common's main functionalities?

Instrumentation of SQL Queries

This feature allows you to create spans around SQL query executions, which helps in tracing the performance and errors of SQL queries.

const { createSpan, context } = require('@opentelemetry/sql-common');

function executeQuery(query) {
  const span = createSpan('executeQuery');
  try {
    // Execute the SQL query
    const result = database.execute(query);
    span.setStatus({ code: 0 }); // Success
    return result;
  } catch (error) {
    span.setStatus({ code: 2, message: error.message }); // Error
    throw error;
  } finally {
    span.end();
  }
}

Context Propagation

This feature allows you to propagate context across asynchronous operations, ensuring that telemetry data is correctly associated with the originating request.

const { context, setSpan } = require('@opentelemetry/sql-common');

function executeQueryWithContext(query) {
  const span = createSpan('executeQueryWithContext');
  const ctx = setSpan(context.active(), span);
  return context.with(ctx, () => {
    try {
      // Execute the SQL query
      const result = database.execute(query);
      span.setStatus({ code: 0 }); // Success
      return result;
    } catch (error) {
      span.setStatus({ code: 2, message: error.message }); // Error
      throw error;
    } finally {
      span.end();
    }
  });
}

Other packages similar to @opentelemetry/sql-common

Keywords

FAQs

Package last updated on 22 Jun 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc