GraphiteClient 0.1.0

GraphiteClient 0.1.0

Vadim SmalCognitiveDissonVladislav AlekseevTim Yusipov 维护。



  • Avito的编码者之地

GraphiteClient

一个轻量级的Swift框架,用于将数据输入到GraphitestatsD

开始使用

安装

Swift包管理器

在您的Package.swift文件中添加依赖项

let package = Package(
    name: "project",
    dependencies: [
        .package(
            url: "https://github.com/avito-tech/GraphiteClient.git", 
            .upToNextMajor(from: "0.1.0")
        ),
    ],
    targets: [
        .target(
            name: "YourProjectName",
            dependencies: [
                "GraphiteClient"
            ]
        )
    ]
)

CocoaPods

要使用CocoaPods将GraphiteClient集成到您的Xcode项目中,请在您的Podfile中指定它

pod 'GraphiteClient', '~> 0.1'

使用方法

import GraphiteClient

let streamProvider = NetworkSocketOutputStreamProvider(
    host: host,
    port: port
)
let easyOutputStream = EasyOutputStream(
    outputStreamProvider: streamProvider,
    errorHandler: { stream, error in
        debugPrint("Graphite stream error: \(error)")
    },
    streamEndHandler: { stream in
        debugPrint("Graphite stream has been closed")
    }
)
try easyOutputStream.open()
let client = GraphiteClient(
    easyOutputStream: easyOutputStream
)
try client.send(
    path: [
        "some",
        "metric",
        "path"
    ],
    value: 42.0,
    timestamp: Date()
)