Giter VIP home page Giter VIP logo

geo-py's Introduction

Tracegen

Generates interface decorators with opentracing support.

Installation

go get github.com/gojuno/tracegen

Example

type Cache interface {
	Set(ctx context.Context, key, value []byte) error
	Get(ctx context.Context, key []byte) (value []byte, err error)
}
tracegen -i Cache -o example/cache_trace.go ./example

Will generate:

type CacheTracer struct {
	next   Cache
	prefix string
}

func NewCacheTracer(next Cache, prefix string) *CacheTracer {
	return &CacheTracer{
		next:   next,
		prefix: prefix,
	}
}

func (t *CacheTracer) Get(in context.Context, in1 []byte) (out []byte, out1 error) {
	span, in := opentracing.StartSpanFromContext(in, t.prefix+".Cache.Get")
	defer func() {
		if out1 != nil {
			ext.Error.Set(span, true)
			span.LogFields(
				log.String("event", "error"),
				log.String("message", out1.Error()),
			)
		}
		span.Finish()
	}()

	return t.next.Get(in, in1)
}

func (t *CacheTracer) Set(in context.Context, in1 []byte, in2 []byte) (out error) {
	span, in := opentracing.StartSpanFromContext(in, t.prefix+".Cache.Set")
	defer func() {
		if out != nil {
			ext.Error.Set(span, true)
			span.LogFields(
				log.String("event", "error"),
				log.String("message", out.Error()),
			)
		}
		span.Finish()
	}()

	return t.next.Set(in, in1, in2)
}

geo-py's People

Contributors

habibutsu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

geo-py's Issues

Add an example script

Many thanks for a nice package. It would be great if you could add an example.py script.

Detect pypy runtime

Need to detecting pypy runtime for selecting native implementation

import sys
is_pypy = '__pypy__' in sys.builtin_module_names

Getting a C Linkage error when installing the package

I'm using macOS high sierra as my OS and my python version is 3.7.0

/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/include/python3.7m/pystate.h:238:15: note: 'curexc_traceback' declared here
        PyObject *curexc_traceback;
                  ^
    15 errors generated.
    error: command 'clang' failed with exit status 1

Has anyone seen a similar issue before? What steps should I take to fix it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.