coopdatadog

package module
v2.16.3 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2025 License: MIT Imports: 14 Imported by: 0

README

Coop Datadog Go package

Build

Plug and play package that wraps base functionally and initialization of Datadog Service.

  • APM, StatsD Initialization
  • StatsD metrics unification

Supported middleware to correlate/extend traceability and logs in Datadog.

  • gRPC Server
  • gRPC Client
  • HTTP - Echo
  • HTTP - Standard library Client
  • Database - GORM
  • Database - Standard library

Documentation

https://pkg.go.dev/github.com/coopnorge/go-datadog-lib/v2

Mocks

To generate or update mocks use gomockhandler. gomockhandler is provided by golang-devtools.

Check mocks
docker compose run --rm golang-devtools gomockhandler -config ./gomockhandler.json check
Generate / Update mocks
docker compose run --rm golang-devtools gomockhandler -config ./gomockhandler.json mockgen

Development workflow

Validate
docker compose run --rm golang-devtools validate
Other targets
docker compose run --rm golang-devtools help

User documentation

User documentation is build using TechDocs and published to Inventory.

To list the commands available for the TechDocs image:

docker compose run --rm help

For more information see the TechDocs Engineering Image.

Documentation validation

To Validate changed documentation:

docker compose run --rm techdocs validate

To validate all documentation:

docker compose run --rm techdocs validate MARKDOWN_FILES=docs/
Documentation preview

To preview the documentation:

docker compose up techdocs

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func GracefulDatadogShutdown deprecated

func GracefulDatadogShutdown()

GracefulDatadogShutdown of executed parallel processes

Deprecated: Use the StopFunc returned coopdatadog.Start() instead.

func StartDatadog deprecated

func StartDatadog(cfg config.DatadogParameters, connectionType ConnectionType) error

StartDatadog parallel process to collect data for Datadog. connectionType flag related to Datadog connection type, it supports HTTP or socket - values will be used from config.DatadogParameters

Deprecated: Use coopdatadog.Start() instead.

Types

type ConnectionType deprecated

type ConnectionType byte

ConnectionType enum type

Deprecated: Use coopdatadog.Start() instead.

const (
	// ConnectionTypeSocket sets the connection to Datadog to go through a UNIX socket
	//
	// Deprecated: ConnectionTypeSocket. ConnectionTypeAuto should be used.
	ConnectionTypeSocket ConnectionType = iota
	// ConnectionTypeHTTP sets the connection to Datadog to go over HTTP
	//
	// Deprecated: ConnectionTypeHTTP. ConnectionTypeAuto should be used.
	ConnectionTypeHTTP
	// ConnectionTypeAuto sets connection to HTTP or UNIX depending on supplied configuration of DD_TRACE_AGENT_URL
	//
	// Deprecated: Use coopdatadog.Start() instead.
	ConnectionTypeAuto
)

type Option added in v2.16.0

type Option func(*options) error

Option is used to configure the behaviour of the Datadog integration.

func WithErrorHandler added in v2.16.0

func WithErrorHandler(handler errors.ErrorHandler) Option

WithErrorHandler allows for setting a custom ErrorHandler to be called on function that may error but does not return an error

func WithMetricsOptions added in v2.16.0

func WithMetricsOptions(metricOptions ...metrics.Option) Option

WithMetricsOptions allows for passing the options for setting up metrics

func WithNoStopTimeout added in v2.16.0

func WithNoStopTimeout() Option

WithNoStopTimeout waits for graceful shutdown to complete regardless of how long.

func WithStopTimeout added in v2.16.0

func WithStopTimeout(timeout time.Duration) Option

WithStopTimeout sets the allowed time for graceful shutdown, defaults to 10 seconds.

type StopFunc added in v2.16.0

type StopFunc func() error

StopFunc is a function signature for functions that stops the Datadog integration.

func Start added in v2.16.0

func Start(ctx context.Context, opts ...Option) (StopFunc, error)

Start the Datadog integration, use the returned Cancel function to stop the Datadog integration. When calling the StopFunc function traces will be flushed and profiling will be stopped to Datadog.

Example
package main

import (
	"context"

	coopdatadog "github.com/coopnorge/go-datadog-lib/v2"
)

func main() {
	err := run()
	if err != nil {
		panic(err)
	}
}

func run() error {
	stop, err := coopdatadog.Start(context.Background())
	if err != nil {
		return err
	}
	defer func() {
		err := stop()
		if err != nil {
			panic(err)
		}
	}()

	// ...

	return nil
}
Output:

Directories

Path Synopsis
Package integration setups up integration tests that tests the combination of multiple server and client packages.
Package integration setups up integration tests that tests the combination of multiple server and client packages.
Code generated by MockGen.
generated/mocks/labstack/echo/v4
Code generated by MockGen.
Code generated by MockGen.
generated/mocks/metric
Code generated by MockGen.
Code generated by MockGen.
Package metric implements custom metrics with Dogstatsd
Package metric implements custom metrics with Dogstatsd
Package metrics implements custom metrics with Dogstatsd
Package metrics implements custom metrics with Dogstatsd
middleware

Jump to

Keyboard shortcuts

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