schema

package
v0.3.0-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2024 License: Apache-2.0 Imports: 13 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultClient = defaultClient(http.DefaultClient)

DefaultClient is the default Client used to fetch schemas. All OpenTelemetry published schema (i.e. ones with Schema Family identifiers https://opentelemetry.io/schemas/<version>) are fetched from a local pre-built cache. All other schema are fetched using the default HTTP client at the remote schema URL.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is used to fetch, cache, and parse schemas.

func NewHTTPClient

func NewHTTPClient(httpClient *http.Client) *Client

NewHTTPClient returns a Client that fetches all requested schema via an HTTP request to the provided schema URL. All fetched schemas are cached.

func NewLocalClient

func NewLocalClient() *Client

NewLocalClient is a static Client pre-loaded with all OpenTelemetry published schema (i.e. ones with Schema Family identifiers https://opentelemetry.io/schemas/<version>).

func NewStaticClient

func NewStaticClient(data map[string]*ast.Schema) *Client

NewStaticClient returns a Client that will only return schemas contained in the passed data. The passed data is a map of schema URL to schema.

func (*Client) Get

func (c *Client) Get(ctx context.Context, schemaURL string) (*ast.Schema, error)

Get fetches and parses the OpenTelemetry schema identified by schemaURL.

type Converter

type Converter struct {
	// contains filtered or unexported fields
}

Converter converts OpenTelemetry objects based on OpenTelemetry schema translations.

func NewConverter

func NewConverter(c *Client) Converter

NewConverter returns a new Converter that uses the Client c to handle all schema fetching. If c is nil, the default client will be used.

func (Converter) MergeResources

func (c Converter) MergeResources(ctx context.Context, schemaURL string, resources ...*resource.Resource) (*resource.Resource, error)

MergeResources creates a new resource by combining resources at the target schemaURL version.

If there are common keys between resources the latter resource will overwrite the former.

Any of the resources not already at schemaURL version will be appropriately upgraded or downgraded to match the version. An error is returned if this is not possible.

func (Converter) Resource

func (c Converter) Resource(ctx context.Context, schemaURL string, orig *resource.Resource) (*resource.Resource, error)

Resource returns a copy of orig with the schema URL set to url and all attributes transformed based on the associated schema. If the schema transformation fails, or url is empty, an error is returned.

Directories

Path Synopsis
cmp

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL