Skip to content

Should @opentelemetry/browser-sdk export combineSdks function? #388

Description

@david-luna

A bit of context

When the implementation of the browser SDK started the instrumentations in this repository were only using the logs API and SDK. So including anything related to traces was just making the package to grow with unused code.

To address that combineSdks was made. The idea behind the function was to have in the package only what is required (logs SDK) but let the users to append other components/SDKs if they need it by providing a function with a specific signature. One use case was to be able to add other signals like traces or metrics.

After some discussions in the SIG about porting the instrumentations from opentelemetry-js and opentelemetry-js-contrib repos it was agreed that fetch and XHR instrumentations will also send Spans. The SDK package included the traces signal in its PR.

The combineSdks function is used internally to merge both start{logs,traces}Sdk functions but is not exported. So at the moment users cannot benefit from it. If they want to add, for example, an SDK for metrics they have to do their own "combine" logic.

So. Should we export the function for the users to make things easier or would that complicate things? I guess the options are

  • keep it internal
  • remove it. that logic can be moved to startBrowserSdk
  • expose it so user can
import { combineSdks } from '@opentelemetry/browser-sdk';
import { startLogsSdk } from '@opentelemetry/browser-sdk/logs';
import { startTracesSdk } from '@opentelemetry/browser-sdk/traces';

const sdkWithMetrics = combineSdks({
  logs: startLogsSdk,
  traces: startTracesSdk,
  metrics: function startMyMetrics (config) {
    // return a WebSdk object
  },
});

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions