# README
Instrumentation Library
This is a simple wrapper for the New Relic API that makes it easier to interact with the New Relic service from your golang code.
Installation
You can install the New Relic wrapper using go get
:
go get -u github.com/SimifiniiCTO/backend-core-lib/instrumentation
Usage
You need to to import the library
import github.com/SimifiniiCTO/backend-core-lib/instrumentation
Then initialize the Instrumentation Client with the following configuration
opts := []instrumentation.Option{
instrumentation.WithServiceName("test-service"),
instrumentation.WithServiceVersion("v1.0.0"),
instrumentation.WithServiceEnvironment("prod"),
instrumentation.WithEnabled(true), // enables instrumentation
instrumentation.WithNewrelicKey("newrelic-license-key"),
instrumentation.WithLogger(zap.L()),
}
client, err := instrumentation.New(opts...)
if err != nil {
...
}
Now you can user the client
object to instrument your applicatuon.
for example, to initiate a trace
ctx := context.Background()
tx := client.StartTransaction("test-transaction") // starts a new transaction
span := client.NewChildSpan("test-span", tx)
defer span.End()
Development
If you want to contribute to this project, you can clone the repository and install the development dependencies:
git clone github.com/SimifiniiCTO/backend-core-lib/instrumentation
cd backend-core-lib/instrumentation
go mod tidy
Please see the contributing guide for more information on how to contribute.
License
This project is licensed under the MIT License - see the LICENSE file for details.
# Functions
`InterceptorLogger` is a function that returns a `logging.Logger` which is used as an interceptor for gRPC requests.
NewServiceTelemetry creates a new Client.
WithClient configures the newrelic client.
WithEnabled configures wether or not instrumentation is enabled.
WithEnableEvents configures wether or not events are enabled.
WithEnableLogger configures wether or not logging is enabled.
WithEnableMetrics configures wether or not metrics are enabled.
WithEnableTracing configures wether or not tracing is enabled.
WithLogger configures the logger.
WithNewrelicKey configures the newrelic key.
WithServiceEnvironment configures the service environment.
WithServiceName configures the service name.
WithServiceVersion configures the service version.
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Variables
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Structs
The `Client` type is a struct that holds information about a service, including its name, version, environment, telemetry settings, New Relic license key, and a logger object.
Counter a metric type that only linearly increases.
Gauge a metric type that can increase and decrease.
Metric encompasses the relative metadata associated with a service level metric being emitted.
No description provided by the author
Summary summarizes numerous facets of a metric.
# Interfaces
The IServiceTelemetry interface defines methods for collecting telemetry data for a service, including tracing, segments, and roundtrippers.
# Type aliases
No description provided by the author
No description provided by the author
Option is a function that configures a Client.
No description provided by the author