sfapmlib

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2022 License: MPL-2.0 Imports: 10 Imported by: 0

README

go-sf-apm-lib

This package collects the profile key, project name, and app name to send the trace data to SnappyFlow. These are collected automatically from the environment variables set by the user. The environment variables to be set are:

  • SF_PROJECT_NAME: specify your project name here
  • SF_APP_NAME: specify your app name here
  • SF_PROFILE_KEY: specify the snappyflow key here

If these environment variables are not set, the values are alternatively fetched from the sfagent's config.yaml file.

Getting started

  • Pre-requisite

    • Run below command to download or update the sf-go-apm-lib package in your current project.
      go get github.com/snappyflow/go-sf-apm-lib
      
  • Example

import _ "github.com/snappyflow/go-sf-apm-lib"

func main() {
    // rest of the application code
}

This package needs to be imported as a blank import solely for its initialization only.

Documentation

Index

Constants

View Source
const (
	ProjectName = "projectName"
	AppName     = "appName"
)

tag values

View Source
const (
	WindowsConfigPath = "C:\\Program Files (x86)\\Sfagent\\config.yaml"
	LinuxConfigPath   = "/opt/sfagent/config.yaml"
)

config.yaml paths

View Source
const (
	GlobalLabels                    = "_tag_projectName=%s,_tag_appName=%s,_tag_profileId=%s"
	ElasticAPMServerURL             = "ELASTIC_APM_SERVER_URL"
	ElasticAPMGlobalLabels          = "ELASTIC_APM_GLOBAL_LABELS"
	ElasticAPMSpanFramesMinDuration = "ELASTIC_APM_SPAN_FRAMES_MIN_DURATION"
	ElasticAPMStackTraceLimit       = "ELASTIC_APM_STACK_TRACE_LIMIT"
	ElasticAPMVerifyServerCert      = "ELASTIC_APM_VERIFY_SERVER_CERT"
	SfProjectName                   = "SF_PROJECT_NAME"
	SfAppName                       = "SF_APP_NAME"
	SfProfileKey                    = "SF_PROFILE_KEY"
)

apm environment variables

View Source
const (
	FramesMinDuration = "1ms"
	StackTraceLimit   = "2"
	VerifyServerCert  = "false"
)

apm environment variables default values

View Source
const (
	EncryptedKey = "U25hcHB5RmxvdzEyMzQ1Ng=="
)

sf decryption key

Variables

This section is empty.

Functions

func InitConfig

func InitConfig() error

InitConfig sets the values from sfagent's config.yaml

func InitEnv

func InitEnv(sfKey string, projectName string, appName string) error

InitEnv sets the values from environment variables

Types

type Config

type Config struct {
	SnappyFlowKey string `json:"key,omitempty" yaml:"key,omitempty"`
	Tags          Tags   `json:"tags,omitempty" yaml:"tags,omitempty"`
}

Config stores the key and tags from config.yaml

func LoadConfigFromFile

func LoadConfigFromFile(path string) (*Config, error)

LoadConfigFromFile loads the config from config.yaml

type SnappyFlowKeyData

type SnappyFlowKeyData struct {
	ProfileID   string `json:"profile_id"`
	TraceServer string `json:"trace_server_url"`
}

SnappyFlowKeyData struct holds content after decryption

type Tags

type Tags map[string]string

Tags holds the project name and app name as provided in config.yaml

Jump to

Keyboard shortcuts

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