instaazurefunction

package module
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 10 Imported by: 0

README

Instana instrumentation for Microsoft Azure Functions

This module contains the instrumentation code for Microsoft Azure functions written in Go that uses the custom runtime.

PkgGoDev

Installation

To add github.com/instana/go-sensor/instrumentation/instaazurefunction to your go.mod file, from your project directory run:

$ go get github.com/instana/go-sensor/instrumentation/instaazurefunction

Usage

Instrumenting a custom handler

To instrument a custom handler, wrap it with instaazurefunction.WrapFunctionHandler() before passing it to the http router.

func handlerFn(w http.ResponseWriter, r *http.Request) {
	// ...
}

func main() {
// Initialize a new sensor.
sensor := instana.NewSensor("my-azf-sensor")

// Instrument your handler before passing it to the http router.
http.HandleFunc("/api/azf-test", instaazurefunction.WrapFunctionHandler(sensor, handlerFn))
}

Refer the instaazurefunction package documentation for more details.

Limitations

  • The instrumentation supports only HTTP and Queue trigger types.
  • The instrumentation cannot support HTTP triggers if enableForwardingHttpRequest is set to true in the host.json file.

Documentation

Overview

Package instaazurefunction provides Instana tracing instrumentation for Microsoft Azure Functions

Example (Handler)

This example demonstrates how to instrument a custom handler for Azure Functions

// (c) Copyright IBM Corp. 2023

package main

import (
	"net/http"

	instana "github.com/instana/go-sensor"
	"github.com/instana/go-sensor/instrumentation/instaazurefunction"
)

// This example demonstrates how to instrument a custom handler for Azure Functions
func main() {
	// Initialize a new sensor.
	sensor := instana.NewSensor("my-azf-sensor")

	// Instrument your handler before passing it to the http router.
	http.HandleFunc("/api/azf-test", instaazurefunction.WrapFunctionHandler(sensor, handlerFn))
}

func handlerFn(w http.ResponseWriter, r *http.Request) {
	// ...
}
Output:

Index

Examples

Constants

View Source
const Version = "0.13.0"

Version is the instrumentation module semantic version

Variables

This section is empty.

Functions

func WrapFunctionHandler

func WrapFunctionHandler(sensor instana.TracerLogger, handler http.HandlerFunc) http.HandlerFunc

WrapFunctionHandler wraps the http handler and add instrumentation data for the specified handlers

Types

type Metadata

type Metadata struct {
	//queueStorage fields
	DequeueCount  int    `json:"DequeueCount,string"`
	PopReceipt    string `json:"PopReceipt"`
	InsertionTime string `json:"InsertionTime"`
	//http fields
	Headers struct {
		UserAgent string `json:"User-Agent"`
	} `json:"Headers"`
	//common info with method name
	Sys struct {
		MethodName string `json:"MethodName"`
	} `json:"sys"`
}

Jump to

Keyboard shortcuts

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