# TiInf

## Introduction

TiInf is a infra wrapper utilities for TiDBCloud teams. By using TiInf, we can get:

- high-quality, ubiquitous tracing(gRPC, GORM, Redis, Resty)
- auto integrated sentry report(gRPC)
- auto integrated prometheus monitoring(gRPC)
- auto integrated server side logging(gRPC)

## Modules

| Modules                  | Latest Version | Description                                                                                                                                                    | Maintainer |
|--------------------------|----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------| --- |
| errs   	                 | v0.3.23   	    | Module for error handling, support error category, inheritance, type assertion, work with HTTP and gRPC, support error code, error message, and status code.   | @jiajunhuang |
| monitor/threadlocal   	  | v0.3.23   	    | Isolate context with goroutine, It simulates a `thread local` area, which can be used to store local variables in different goroutines.                        | @clark1013 |
| monitor/tilog   	        | v0.3.23   	    | A self contained logging library, based on zap.                                                                                                                | @clark1013 |
| monitor/tisentry   	     | v0.3.27   	    | A error tracking library, based on sentry.                                                                                                                     |@jiajunhuang |
| monitor/titracing   	    | v0.3.23   	    | A collection of tools, APIs, and SDKs. Use it to instrument, generate, collect, and export telemetry data (metrics, logs, and traces), based on OpenTelemetry. | @clark1013 |
| sdk/auditlog   	         | v0.3.23   	    | AuditLog SDK，used for submit auditlog.                                                                                                                         | @clark1013|
| sdk/auth   	             | v0.3.23   	    | RBAC SDK，used for identity and permission check.                                                                                                                            |@xingying9999|
| sdk/measure   	          | v0.3.23   	    | Measure SDK，used for mearsure report.                                                                                                                             |@wxtwine|
| storage/tigorm   	       | v0.3.23   	    | A Cloud Platform powered GORM, which provides abilities for logging, tracing, and so on.                                                                       |@jiajunhuang|
| storage/tiredis   	      | v0.3.23   	    | A Cloud Platform powered Redis, which provides abilities for logging, tracing, and so on.                                                                       |@jiajunhuang|
| transport/http   	       | v0.3.23   	    | A Cloud Platform powered Gin, which provides abilities for logging, authorize, authentication, tracing, and so on.                                            |@jiajunhuang|
| transport/tieventbus   	 | v0.3.23   	    | Eventbus SDK，used for publish event message.                                                                                                                   |@yitso|
| transport/tigrpc   	     | v0.3.23   	    | A Cloud Platform powered GRPC, which provides abilities for authentication, authentication, tracing, monitor, and so on.                                       |@jiajunhuang|

## Getting Started

### Import through tiinf (recommended)

We recommend that you directly use tiinf to import all components together, bellow is an example.

```go
import "github.com/tidbcloud/tiinf/tiinf"

// create a new tiinf
inf := tiinf.NewInf()

// initialize
inf.Init(tiinf.WithConfigFile(TIINF_CONFIG_FILE))

// start all components
inf.Run()
```
More details is [here](./examples/tiinf/README.md)


### Import One module

If you only want to import one module to your project, you can follow the [examples](./examples/)


## How to contribute

When you want to contribute to this library, you have to do the following steps:

1. Cloning a fork by running `git@github.com:tidbcloud/tiinf`
2. Creating a branch to work on by running `git checkout -b <Your Branch Name>`
3. Making and pushing changes
4. Making a pull request in Github
5. Make sure you had passed all the CI testing
6. Add a tag to your commits, e.g. when you want to release auditlog v1.0.0, you need to add a tag `sdk/auditlog/v1.0.0`
7. Publish a release note in Github releases page: https://github.com/tidbcloud/tiinf/releases/new
